package com.tedu;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class T1 {
    public static void main(String[] args) throws IOException, TimeoutException {
        ConnectionFactory f=new ConnectionFactory();
        f.setHost("192.168.64.140");
        f.setPort(5672);
        f.setUsername("admin");
        f.setPassword("admin");


        Connection con=f.newConnection();
        Channel c=con.createChannel();
//      声明一个消息队列helloworld
        /*
        * @param
        * 1.队列名
        * 2.是否是持久队列
        * 3.是否是排他（独占）队列
        * 4.是否自动删除（自动判断，没有消费者就删除）
        * 5.队列其它属性*/
        c.queueDeclare("task_queues",true,false,false,null);
        /*@Param 1.交换机
        * */
//        发送消息
        c.basicPublish("", "task_queues", null, "fuck world".getBytes());
        System.out.println("haol");
        c.close();
    }
}
